package com.delicious.core.dict.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.delicious.core.dict.vo.DictTypePageRequest;
import com.delicious.core.dict.vo.DictTypePageResponse;
import com.delicious.core.base.BaseResponse;
import com.delicious.core.dict.vo.DictTypeRequest;
import com.delicious.core.dict.vo.DictTypeResponse;
import com.delicious.core.dict.service.SysDictTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Api("字典类型")
@RestController
@RequestMapping("/dictTypes")
@RequiredArgsConstructor
public class SysDictTypeController {

    private final SysDictTypeService dictTypeService;

    @ApiOperation(value = "字典类型分页列表")
    @GetMapping
    public BaseResponse<Page<DictTypePageResponse>> listDictTypePages(DictTypePageRequest queryParams) {
        Page<DictTypePageResponse> result = dictTypeService.listDictTypePages(queryParams);
        return BaseResponse.of(result);
    }

    @ApiOperation(value = "字典类型表单详情")
    @GetMapping("/detail/{id}")
    public BaseResponse<DictTypeResponse> getDictTypeFormData(@ApiParam("字典ID") @PathVariable Long id) {
        DictTypeResponse dictTypeResponse = dictTypeService.getDictTypeFormData(id);
        return BaseResponse.of(dictTypeResponse);
    }

    @ApiOperation(value = "新增字典类型")
    @PostMapping
    public BaseResponse saveDictType(@RequestBody DictTypeRequest dictTypeForm) {
        return dictTypeService.saveDictType(dictTypeForm);
    }
//
//    @ApiOperation(value = "修改字典类型")
//    @PutMapping("/{id}")
//    public Result updateDict(@PathVariable Long id, @RequestBody DictTypeForm dictTypeForm) {
//        boolean status = dictTypeService.updateDictType(id, dictTypeForm);
//        return Result.judge(status);
//    }
//
//    @ApiOperation(value = "删除字典类型")
//    @DeleteMapping("/{ids}")
//    public Result deleteDictTypes(
//            @ApiParam("字典类型ID，多个以英文逗号(,)分割") @PathVariable String ids
//    ) {
//        boolean result = dictTypeService.deleteDictTypes(ids);
//        return Result.judge(result);
//    }
}
